#include <vector>
#include <iostream>
#include <stdio.h>
#include <vector>
#include "mycode.h"

using namespace std;

	vector<vector<int> > Matrices::getmatrix()
	{
		return matrix;
	}
	Matrices::Matrices()
	{

	}
	Matrices::Matrices (int a,int b, int c, int d)
	{
		vector<int>row;
		row.push_back(a);
		row.push_back(b);
		matrix.push_back(row);
		row.clear();
		row.push_back(c);
		row.push_back(d);
		matrix.push_back(row);
		row.clear();
	}

	Matrices::Matrices(int num)
	{
		int rownum=0;
		int colnum=0;
		int temp=0;
		int i=0;
		int j=0;
		cout<<"Enter number of rows "<<endl;
		cin>>rownum;
		cout<<"Enter number of columns"<<endl;
		cin>>colnum;

		for (i=0;i<colnum;i++)
		{
			vector <int> row;
			for (j=0;j<rownum;j++)
			{
				cin>>temp;
				row.push_back(temp);
			}
			matrix.push_back(row);
		}
	}

	void Matrices::initializematrix(vector<vector<int> > inputmatrix)
	{
		unsigned int j=0;
		unsigned int i=0;
		
		for (i=0;i<inputmatrix.size();i++)
		{
			vector <int> temp;
			for (j=0;j<inputmatrix[0].size();j++)
			{
				temp.push_back(inputmatrix[i][j]);
			}
			matrix.push_back(temp);
		}
	}
	void Matrices::displaymatrix()
	{
		unsigned int j=0;
		unsigned int i=0;
		for (i=0;i<matrix.size();i++)
		{
			for (j=0;j<matrix[0].size();j++)
			{
				cout<<matrix[i][j]<<endl;
			}
		}
	}
	Matrices Matrices::operator +(Matrices mat1)
	{
		Matrices T;
		unsigned int i=0;
		unsigned int j=0;
		for(i = 0; i < mat1.matrix.size(); i++)
		{
			vector <int> temp;
			for(j = 0; j < mat1.matrix[0].size(); j++)
			{
				temp.push_back(matrix[i][j]+ mat1.matrix[i][j]);
			} 
			T.matrix.push_back(temp);
		}

		return T;
	}
	Matrices Matrices::operator -(Matrices mat1)
	{
		Matrices T;
		unsigned int i=0;
		unsigned int j=0;
		for(i = 0; i < mat1.matrix.size(); i++)
		{
			vector <int> temp;
			for(j = 0; j < mat1.matrix[0].size(); j++)
			{
				temp.push_back(matrix[i][j]- mat1.matrix[i][j]);
			} 
			T.matrix.push_back(temp);
		}

		return T;
	}
	Matrices Matrices::operator *(Matrices mat1)
	{
		Matrices T;
			unsigned int i=0;
			unsigned int j=0;
			unsigned int k=0;
			int temp=0;

			if(matrix.size() == mat1.matrix[0].size())
			{

				for( i=0;i<mat1.matrix.size();i++)
				{
					vector<int> tempvector;
					for( j=0;j<matrix[0].size();j++)
					{
						
						for(k=0;k<matrix.size();k++)
						{
							temp=temp+(mat1.matrix[i][k]*matrix[k][j]);
						}
						tempvector.push_back(temp);
						temp=0;
					}
					T.matrix.push_back(tempvector);
				} 				
				
				 return T;
			}
			else return T;
			

	}
